package org.iwidget.desktop.model;
import java.util.ArrayList;
import org.w3c.dom.*;

/**
 *
 * @author Muhammad Hakim A
 */

public class AboutElement
{

    public AboutElement(WidgetElement widget)
    {
        this.widget = widget;
        images = new ArrayList();
    }

    public ArrayList getImages()
    {
        return images;
    }

    public void addImage(String string)
    {
        images.add(string);
    }

    public void parse(Node node)
        throws Exception
    {
        NamedNodeMap map = node.getAttributes();
        for(int iCtr = 0; iCtr < map.getLength(); iCtr++)
        {
            Node attr = map.item(iCtr);
            if(attr.getNodeName().equals("image"))
                addImage(attr.getNodeValue());
        }

        NodeList nodes = node.getChildNodes();
        for(int iCtr = 0; iCtr < nodes.getLength(); iCtr++)
        {
            Node childNode = nodes.item(iCtr);
            String nodeName = childNode.getNodeName();
            String nodeValue = childNode.getNodeValue();
            if(childNode.getFirstChild() != null && nodeName.equals("image"))
                addImage(childNode.getFirstChild().getNodeValue());
        }

    }

    private WidgetElement widget;
    private ArrayList images;
}